<%@ page import="condominios.util.utilitario" %>
<%@ page import="condominios.modelo.Visita" %>
<%@ page import="condominios.modelo.Persona" %>
<%@ page import="java.util.*" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sistema de Administraci&oacute;n de Condominios - Pagar Cuotas</title>

<%@include file="include/header.jsp" %>
</head>
<body>

<%@include file="include/menu.jsp" %>

<%
Collection<Persona> personas= (Collection<Persona>)request.getAttribute("DATA_LIST_RESIDENTE");
%>

<div class="container">
		<div class="hero-unit">
	    	<h2><strong>Registro de visitas</strong></h2><br>
	    </div>
	    
	    <form action="VisitaBuscarServlet" method="post" class="form">
	    <div class="row">
		    <div class="col-xs-2">Residente Propietario   
		    </div>
		    <div class="col-xs-8">
				<input type="text" name="txtresidente" id="txtresidente" class="form-control" autofocus/>
		    </div>
		    <div class="col-xs-2">
		    	<input type="submit" value="Filtrar" id="btnfiltrar" name="btnfiltrar" class="btn btn-primary">
		    </div>
	    </div>
	    </form>		    	
	    </br>
	    </br>
	    <div class="table-responsive">
	    	
			<table class="table table-striped table-bordered table-hover">
			<tr>
				<th>Residente</th>
				<th>DNI Visita</th>
				<th>Nombre Visita</th>
				<th>Fecha/Hora Visita</th>
			</tr>
			<%
			Collection<Visita> list = (Collection<Visita>) request.getAttribute("DATA_LIST");
				if (list != null) {
					for (Visita item : list) {
			%>			
			<tr>
				<td><%=item.getPersona().getobtenerNombresCompletos()%></td>
				<td><%=item.getNumDocumento()%></td>
				<td><%=item.getNombreCompletoVisita()%></td>
				<td><%=condominios.util.utilitario.fnFechaHora(item.getFechaHora())%></td>				
			</tr>
			<%
				}
			} %>
			</table>
			
		</div>
		
	<div>
	<input type="button" value="Nuevo" id="btnNuevo" name="nuevo" class="btn btn-primary" data-toggle="modal" data-target="#myModal" data-estado="1"/>
	
	</div>

<%=utilitario.fnMensajeTrans(request.getAttribute("RESP_TRANS"))%>

	<!--INI: Paginacion
	<div class="row">
	   	<div class="col-md-12" align="right">
		   	<nav>
			  <ul class="pagination">
			    <li>
			      <a href="#" aria-label="Previous">
			        <span aria-hidden="true">&laquo;</span>
			      </a>
			    </li>
			    <li><a href="#">1</a></li>
			    <li><a href="#">2</a></li>
			    <li><a href="#">3</a></li>
			    <li><a href="#">4</a></li>
			    <li><a href="#">5</a></li>
			    <li>
			      <a href="#" aria-label="Next">
			          <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
			  </ul>
			</nav>
	   	</div>
	</div>
	FIN: Paginacion -->


	<!-- INI: Modal -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">Registro de Visita</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" role="form" method="post" action="VisitaInsertarServlet">
						
						<div class="form-group hidden">
							<label for="txtid" class="control-label col-xs-3">ID</label>
							<div class="col-xs-9">
								<input type="text" class="form-control" name="txtid" id="txtid" readonly />
							</div>
						</div>
						<div class="form-group">
							<label for="ddlResidente" class="control-label col-xs-3">Residente</label>
							<div class="col-xs-9">
								<select class="form-control" name="ddlResidente" id="ddlResidente" required >
									<option value="">Seleccione</option>
									<%
									//ArrayList<Persona> personas= (ArrayList<Persona>)request.getAttribute("DATA_LIST_RESIDENTE");
									if(personas!= null){
										for(Persona item : personas){
									%>
									<option value="<%=item.getIdPersona()%>"><%=item.getobtenerNombresCompletos() %></option>
									<%
										}
									}
									%>
									
								</select>
							</div>
							
						</div>
						
						<fieldset>
						<legend>Datos del Visitante</legend>
						<div class="control-group">
						
							<div class="form-group">
								<label for="txtdni" class="control-label col-xs-3">DNI</label>
								<div class="col-xs-9">
									<input type="text" class="form-control" name="txtdni" id="txtdni" placeholder="DNI" maxlength="8" pattern="[0-9]{8}" required />
								</div>
							</div>
							<div class="form-group">
								<label for="txtnombre" class="control-label col-xs-3" >Nombres</label>
								<div class="col-xs-9">
									<input type="text" class="form-control" name="txtnombre" id="txtnombre" placeholder="Nombres" maxlength="15" required/>
								</div>			
							</div>
							<div class="form-group">
								<label for="txtpaterno" class="control-label col-xs-3" >Apellido Paterno</label>
								<div class="col-xs-9">
									<input type="text" class="form-control" name="txtpaterno" id="txtpaterno" placeholder="Apelldio Paterno" maxlength="25" required />
								</div>			
							</div>
							<div class="form-group">
								<label for="txtmaterno" class="control-label col-xs-3" >Apellido Materno</label>
								<div class="col-xs-9">
									<input type="text" class="form-control" name="txtmaterno" id="txtmaterno" placeholder="Apellido Materno" maxlength="25" required />
								</div>			
							</div>
						</div>
						</fieldset>
						
						<div class="form-group">
							<label for="txtfechahora" class="control-label col-xs-3">Fecha y hora</label>
							<div class="col-xs-9">
								<input type="datetime-local" class="form-control" name="txtfechahora" id="txtfechahora" required/>
							</div>
						</div>
												
						<div class="form-group">
							<div class="col-xs-offset-3 col-xs-9">
								<input type="submit" value="Grabar" name="btngrabar" id="btngrabar" class="btn btn-primary" />
								<input type="button" value="Cancelar" class="btn btn-default" data-dismiss="modal" />
							</div>						
						</div>
					
					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- FIN: Modal -->
	
	
</div>


</body>
</html>